<?php
define('SALT', '2020yzwcv2'); //签名加点盐

header('content-type:text/html;charset=utf-8');

function getToken($id, $award, $name)
{
    return substr(md5($id . $award . $name . SALT), 0, 6);
}

function awardToChinese($award) {
    switch ($award) {
        case 4:
            return '优秀奖\r\n内容：“满25元减1元”代金卷一张';
        case 3:
            return '三等奖\r\n内容：贴纸两张、“满25元减1元”代金卷一张';
        case 2:
            return '二等奖\r\n内容：明信片一张、“满50元减5元”代金卷一张';
        case 1:
            return '一等奖\r\n内容：铁质书签一个、“满50元减5元”代金卷一张';
        case 0:
            return '特等奖\r\n内容：帆布袋(单面)一个';
    }
}

if (empty($_GET['id']) || !isset($_GET['award']) || empty($_GET['name']) || empty($_GET['token']))
    exit();

if (getToken($_GET['id'], $_GET['award'], $_GET['name']) !== $_GET['token']) {
    echo "<script>\r\nalert(\"无效奖卷！\");\r\n</script>";
    exit();
}

echo "<script>\r\n";
echo 'alert("编号：' . $_GET['id'] . '\r\n姓名：' . $_GET['name'] . '\r\n奖项：' . awardToChinese($_GET['award']) . '");';
echo "</script>\r\n";